import {INPUT_CHANGE, ADD_LIST ,DEL_ITEM, GET_LIST} from './activeType'

const defaultState ={
    inputValue:'',
    list:['a','b','c','d','e','f']
}
const initialState = (state = defaultState,action)=>{
    let newState = JSON.parse(JSON.stringify(state))
    switch(action.type){
        case INPUT_CHANGE:
            newState.inputValue = action.value
            return newState
        case ADD_LIST:
            newState.list.push(newState.inputValue)
            newState.inputValue = ''
            return newState
        case DEL_ITEM:
            newState.list.splice(action.value,1)
            return newState
        case GET_LIST:
            newState.list = action.value
            return newState
        default:
            break;
    }
    return state
}

export default initialState